/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gmao.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Amine
 */
@Entity
@Table(name = "employe")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Employe.findAll", query = "SELECT e FROM Employe e"),
    @NamedQuery(name = "Employe.findByNom", query = "SELECT e FROM Employe e WHERE e.nom = :nom"),
    @NamedQuery(name = "Employe.findByPrenom", query = "SELECT e FROM Employe e WHERE e.prenom = :prenom"),
    @NamedQuery(name = "Employe.findByMatricule", query = "SELECT e FROM Employe e WHERE e.matricule = :matricule"),
    @NamedQuery(name = "Employe.findByCommentaireEmploye", query = "SELECT e FROM Employe e WHERE e.commentaireEmploye = :commentaireEmploye")})
public class Employe implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Column(name = "nom")
    private String nom;
    
    @Column(name = "prenom")
    private String prenom;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 5)
    @Column(name = "matricule")
    private String matricule;
    @Size(max = 2147483647)
    @Column(name = "commentaire_employe")
    private String commentaireEmploye;
    @JoinTable(name = "employe_interv", joinColumns = {
        @JoinColumn(name = "matricule", referencedColumnName = "matricule")}, inverseJoinColumns = {
        @JoinColumn(name = "ident_intervention", referencedColumnName = "ident_intervention")})
    @ManyToMany
    private List<Intervention> interventionList;
    @JoinTable(name = "mach_employe", joinColumns = {
        @JoinColumn(name = "matricule", referencedColumnName = "matricule")}, inverseJoinColumns = {
        @JoinColumn(name = "id_machine", referencedColumnName = "id_machine")})
    @ManyToMany
    private List<Machine> machineList;
    @OneToMany(mappedBy = "matricule")
    private List<Tache> tacheList;
    @JoinColumn(name = "id_atelier", referencedColumnName = "id_atelier")
    @ManyToOne
    private Atelier idAtelier;

    public Employe() {
    }

    public Employe(String matricule) {
        this.matricule = matricule;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public String getMatricule() {
        return matricule;
    }

    public void setMatricule(String matricule) {
        this.matricule = matricule;
    }

    public String getCommentaireEmploye() {
        return commentaireEmploye;
    }

    public void setCommentaireEmploye(String commentaireEmploye) {
        this.commentaireEmploye = commentaireEmploye;
    }

    @XmlTransient
    public List<Intervention> getInterventionList() {
        return interventionList;
    }

    public void setInterventionList(List<Intervention> interventionList) {
        this.interventionList = interventionList;
    }

    @XmlTransient
    public List<Machine> getMachineList() {
        return machineList;
    }

    public void setMachineList(List<Machine> machineList) {
        this.machineList = machineList;
    }

    @XmlTransient
    public List<Tache> getTacheList() {
        return tacheList;
    }

    public void setTacheList(List<Tache> tacheList) {
        this.tacheList = tacheList;
    }

    public Atelier getIdAtelier() {
        return idAtelier;
    }

    public void setIdAtelier(Atelier idAtelier) {
        this.idAtelier = idAtelier;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (matricule != null ? matricule.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Employe)) {
            return false;
        }
        Employe other = (Employe) object;
        if ((this.matricule == null && other.matricule != null) || (this.matricule != null && !this.matricule.equals(other.matricule))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gmao.entities.Employe[ matricule=" + matricule + " ]";
    }
    
}
